﻿// Builders/AmisBuilder.cs
using AmisSdk.Models;
using Newtonsoft.Json;

namespace AmisSdk.Builders
{
    public class AmisBuilder
    {
        private readonly AmisConfig _config;

        public AmisBuilder()
        {
            _config = new AmisConfig();
        }

        /// <summary>
        /// 设置 AMIS schema。
        /// </summary>
        public AmisBuilder SetSchema(string schema)
        {
            _config.Schema = schema;
            return this;
        }

        /// <summary>
        /// 设置预置数据。
        /// </summary>
        public AmisBuilder SetData(object data)
        {
            _config.Data = data;
            return this;
        }

        /// <summary>
        /// 设置页面主体内容。
        /// </summary>
        public AmisBuilder SetBody(object body)
        {
            _config.Body = body;
            return this;
        }

        /// <summary>
        /// 构建 JSON 配置字符串。
        /// </summary>
        public string Build()
        {
            return JsonConvert.SerializeObject(_config, Formatting.Indented);
        }

        /// <summary>
        /// 获取 AMIS 配置对象。
        /// </summary>
        public AmisConfig GetConfig()
        {
            return _config;
        }
    }
}
